﻿#include "InstructionThermostatTargetTemperature.h"

__SCRIPTINSTRUCTION_REGISTER(InstructionThermostatTargetTemperature,ScriptInstruction::Instruction_Thermostat_TargetTemperature,&InstructionThermostatTargetTemperature::fromByteArray1);

InstructionThermostatTargetTemperature::InstructionThermostatTargetTemperature()
{
  instructionFlag = Instruction_Thermostat_TargetTemperature;
}

InstructionThermostatTargetTemperature::InstructionThermostatTargetTemperature(InstructionThermostatTargetTemperature const& instructionThermostatTargetTemperature)
{
  *this=instructionThermostatTargetTemperature;
}

InstructionThermostatTargetTemperature& InstructionThermostatTargetTemperature::operator=(InstructionThermostatTargetTemperature const & instructionThermostatTargetTemperature)
{
  *(ScriptInstruction*)this=instructionThermostatTargetTemperature;
  temperature=instructionThermostatTargetTemperature.temperature;
  return *this;
}

InstructionThermostatTargetTemperature::~InstructionThermostatTargetTemperature()
{}

QString InstructionThermostatTargetTemperature::toString()
{
  return QStringLiteral("设置温箱目标温度，温度：%1℃").arg(temperature,0,'f',4);
}

QByteArray InstructionThermostatTargetTemperature::toByteArray()
{
  return QByteArray().append((char*)&temperature,sizeof (temperature));
}

InstructionThermostatTargetTemperature* InstructionThermostatTargetTemperature::clone()
{
  return new InstructionThermostatTargetTemperature(*this);
}

ScriptInstruction* InstructionThermostatTargetTemperature::fromByteArray1(char * const src,int size,int * offset)
{
  if((size-*offset)<byteArraySize)
    {
      return Q_NULLPTR;
    }
  InstructionThermostatTargetTemperature* instructionThermostatTargetTemperature=new InstructionThermostatTargetTemperature();
  instructionThermostatTargetTemperature->temperature=*(float*)(src+*offset);
  *offset+=sizeof (temperature);
  return instructionThermostatTargetTemperature;
}

float InstructionThermostatTargetTemperature::getTemperature()
{
  return temperature;
}

InstructionThermostatTargetTemperature* InstructionThermostatTargetTemperature::setTemperature(float temperature)
{
  this->temperature=temperature;
  return this;
}
